/* eslint-disable vue/html-indent */ /* eslint-disable vue/html-indent */
<template>
  <div class="cs-page-container">
    <div class="cs-filter-container">
      <el-select v-model="listQuery.channel" filterable clearable placeholder="渠道">
        <el-option
          v-for="(channel, i) in channels"
          :key="i"
          :label="channel"
          :value="channel"
        />
      </el-select>
      <el-select
        v-model="listQuery.bundleId"
        clearable
        placeholder="包名"
      >
        <el-option label="花伴交友app安卓" value="com.vchat.flower" />
        <el-option label="花伴交友app苹果" value="com.vchat.flower.ios" />
        <el-option label="花伴约会app安卓" value="com.date.flower" />
        <el-option label="花伴约会app苹果" value="com.date.flower.ios" />
        <el-option label="成人约会圈app安卓" value="com.chengren.yhq" />
        <el-option label="他趣附近约会app安卓" value="com.funnychat.mask" />
      </el-select>
      <el-date-picker
        v-model="daterangeValue"
        :picker-options="daterangePickerOptions"
        type="daterange"
        align="right"
        unlink-panels
        range-separator="至"
        start-placeholder="起始时间"
        end-placeholder="结束时间"
        value-format="yyyy-MM-dd"
        clearable
        @change="daterangeChangedTimestamp"
      />
      <el-button
        type="primary"
        icon="el-icon-search"
        :loading="listLoading"
        @click="handleFilter"
      >
        查询
      </el-button>
      <el-button
        type="info"
        size="small"
        icon="el-icon-refresh-right"
        @click="resetFilter"
      >
        重置
      </el-button>
    </div>
    <div class="cs-filter-result">
      <el-table
        v-loading="listLoading"
        :data="list"
        :height="'calc(100vh - 250px)'"
        border
        fit
        size="small"
        highlight-current-row
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
      >
        <el-table-column align="center" label="日期" width="100">
          <template slot-scope="{ row }">
            <span>{{
              (row.targetDate ) | parseTime('{y}-{m}-{d}')
            }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="激活人数">
          <template slot-scope="{ row }">
            <span>{{ row.activateCount }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="登录人数">
          <template slot-scope="{ row }">
            <span>{{ row.activeCount }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="总提现金额" width="100">
          <template slot-scope="{ row }">
            <span>{{ row.totalWithdraw / 100 }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="申请次数">
          <template slot-scope="{ row }">
            <span>{{ row.applyCount }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="拒绝次数">
          <template slot-scope="{ row }">
            <span>
              {{ row.refuseCount }}
            </span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="成功次数">
          <template slot-scope="{ row }">
            <span>{{ row.successCount }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="失败次数">
          <template slot-scope="{ row }">
            <span>{{ row.failCount }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="积分存量">
          <template slot-scope="{ row }">
            <span>{{ row.totalPoint }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="积分兑换钻石消耗" width="150">
          <template slot-scope="{ row }">
            <span>{{ row.forDiamondConsume }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="总收益">
          <template slot-scope="{ row }">
            <span>{{ row.totalAmount / 100 }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="文字聊天收益" width="120">
          <template slot-scope="{ row }">
            <span>{{ row.textChatAmount / 100 }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="语音聊天收益" width="100">
          <template slot-scope="{ row }">
            <span>{{ row.voiceChatAmount / 100 }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="视频聊天收益" width="100">
          <template slot-scope="{ row }">
            <span>{{ row.videoChatAmount / 100 }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="私照/视频收益" width="100">
          <template slot-scope="{ row }">
            <span>{{ row.photoVideoAmount / 100 }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="礼物收益">
          <template slot-scope="{ row }">
            <span>{{ row.giftAmount / 100 }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="任务收益">
          <template slot-scope="{ row }">
            <span>{{ row.taskAmount / 100 }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="邀请徒弟收益" width="100">
          <template slot-scope="{ row }">
            <span>{{ row.apprenticeAmount / 100 }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="徒弟分成收益" width="100">
          <template slot-scope="{ row }">
            <span>{{ row.apprenticeShareAmount / 100 }}</span>
          </template>
        </el-table-column>
      </el-table>
      <TablePagination
        :current-page="listQuery.page"
        :limit="listQuery.limit"
        :total="total"
        :loading="listLoading"
        @handleSizeChange="handleSizeChange"
        @handleCurrentChange="handleCurrentChangeOffset"
      />
    </div>
  </div>
</template>

<script>
import TablePagination from '@/components/TablePagination'
import DATEPICKER_OPTIONS from '@/config/datepickerOptions'
import { xhrWithdrawList } from '@api/analysis'

export default {
  name: 'WithdrawList',
  components: { TablePagination },
  data() {
    return {
      list: [],
      channels: [],
      total: 0,
      listQuery: {
        offset: 0,
        limit: 10,
        startTime: null,
        endTime: null,
        channel: null,
        bundleId: null,
        gender: null
      },
      daterangeValue: '',
      daterangePickerOptions: DATEPICKER_OPTIONS.daterangePickerOptions
    }
  },
  created() {
    this.getChannels()
    this.doSearch()
  },
  methods: {
    getChannels() {
      this.xhrGetChannels().then(resp => {
        this.channels = resp.data
      })
    },
    doSearch() {
      xhrWithdrawList(this.listQuery).then(resp => {
        this.listLoading = false
        this.total = resp.data.count
        this.list = resp.data.list
      })
    }
  }
}
</script>
